package com.mop.service;

import com.mop.mapper.ItemMapper;
import com.mop.pojo.Item;
import com.mop.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

@Service
public class ItemServiceImpl implements ItemService{
    @Autowired
    private ItemMapper itemMapper;




    @Override
    public void addUser(Item item) {
        itemMapper.addUser(item);
    }

    @Override
    public void deleteItem(Integer id) {
        itemMapper.deleteItem(id);
    }

    @Override
    public Item findItemById(Integer id) {
        Item item=itemMapper.findItemById(id);
        return item;
    }

    @Override
    public void updateItem(Item item) {
        itemMapper.updateItem(item);
    }

    @Override
    public PageResult getItemList(PageResult pageResult) {
        //1.获取记录总和
        long total=itemMapper.getItemList();
        //2.获取分页查询
        int size =pageResult.getPageSize();//条数
        int start=(pageResult.getPageNum()-1)*size;
        String query=pageResult.getQuery();//查询条件
List<Item> list=itemMapper.findUserLimit(query,start,size);
        pageResult.setTotal(total).setRows(list);
        return pageResult;
    }

    @Override
    public void updateStatus(Item item) {
        itemMapper.updateStatus(item);
    }



}
